//
//  VoiceCell.m
//  Molian
//
//  Created by wansong on 4/27/15.
//  Copyright (c) 2015 xiaocan. All rights reserved.
//

#import "VoiceCell.h"

@implementation VoiceCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.selectionStyle = UITableViewCellSelectionStyleNone;

        
        //推荐标题
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.textColor = [UIColor grayColor];
        self.titleLabel.textAlignment = NSTextAlignmentRight;
        self.titleLabel.font = [UIFont fontWithName:FontName size:15];//改字体和大小
        self.titleLabel.adjustsFontSizeToFitWidth = YES;
        [self.contentView addSubview:self.titleLabel];
        
        // 声线按钮
        self.voiceBtn = [[UIButton alloc]init];
        self.voiceBtn.layer.masksToBounds = YES;
        [self.voiceBtn.layer setCornerRadius:15];
        self.voiceBtn.titleLabel.font = [UIFont fontWithName:FontName size:15];
        self.voiceBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.voiceBtn setBackgroundImage:[UIImage imageWithColor:APPCOLOR(1)] forState:UIControlStateNormal];
        [self.voiceBtn setImage:[UIImage imageNamed:@"voice_play_3"] forState:UIControlStateNormal];
//        CGFloat imgWidth = self.voiceBtn.imageView.frame.size.width;
//        CGFloat btnWidth = self.voiceBtn.frame.size.width;
//        self.voiceBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, imgWidth);
//        self.voiceBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -100, 0, 0);
//        self.voiceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        [self.contentView addSubview:self.voiceBtn];
        
        // 删除按钮
        self.delBtn = [[UIButton alloc]init];
        [self.delBtn setBackgroundImage:[UIImage imageNamed:@"voice_delete_normal"] forState:UIControlStateNormal];
        [self.delBtn setHidden:YES];
        [self.contentView addSubview:self.delBtn];
        
        CATransition *trans=[[CATransition alloc]init];
        [trans setType:kCATransitionReveal];
        [trans setSubtype:kCATransitionFromRight];
        [trans setDuration:0.5];
        [self.layer addAnimation:trans forKey:nil];
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.titleLabel.frame = CGRectMake(10, 0, 70, 50);
    self.voiceBtn.frame = CGRectMake(90, 10, 80, 30);
    self.delBtn.frame = CGRectMake(90+80+10, 15, 20, 20);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
